home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / starscape-logo.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  5.6 KB  |  168 lines

  1. ;  Nova Starscape
  2. ;  Create a text effect that simulates an eerie alien glow around text
  3.  
  4. (define (find-blend-coords w
  5.                h)
  6.   (let* ((denom (+ (/ w h) (/ h w)))
  7.      (bx    (/ (* -2 h) denom))
  8.      (by    (/ (* -2 w) denom)))
  9.     (cons bx by)))
  10.  
  11. (define (find-nova-x-coord drawable
  12.                x1
  13.                x2
  14.                y)
  15.   (let* ((x 0)
  16.      (alpha 3)
  17.      (range (- x2 x1))
  18.      (min-clearance 5)
  19.      (val '())
  20.      (val-left '())
  21.      (val-right '())
  22.      (val-top '())
  23.      (val-bottom '())
  24.      (limit 100)
  25.      (clearance 0))
  26.     (while (and (= clearance 0) (> limit 0))
  27.        (set! x (+ (rand range) x1))
  28.        (set! val (cadr (gimp-drawable-get-pixel drawable x y)))
  29.        (set! val-left (cadr (gimp-drawable-get-pixel drawable (- x min-clearance) y)))
  30.        (set! val-right (cadr (gimp-drawable-get-pixel drawable (+ x min-clearance) y)))
  31.        (set! val-top (cadr (gimp-drawable-get-pixel drawable x (- y min-clearance))))
  32.        (set! val-bottom (cadr (gimp-drawable-get-pixel drawable x (+ y min-clearance))))
  33.        (if (and (= (aref val alpha) 0) (= (aref val-left alpha) 0) (= (aref val-right alpha) 0)
  34.             (= (aref val-top alpha) 0) (= (aref val-bottom alpha) 0))
  35.            (set! clearance 1) (set! limit (- limit 1))))
  36.     x))
  37.  
  38. (define (apply-starscape-logo-effect img
  39.                      logo-layer
  40.                      size
  41.                      glow-color)
  42.   (let* ((border (/ size 4))
  43.      (grow (/ size 30))
  44.      (offx (* size 0.03))
  45.      (offy (* size 0.02))
  46.      (feather (/ size 4))
  47.      (shadow-feather (/ size 25))
  48.      (width (car (gimp-drawable-width logo-layer)))
  49.      (height (car (gimp-drawable-height logo-layer)))
  50.      (w (* (/ (- width (* border 2)) 2.0) 0.75))
  51.      (h (* (/ (- height (* border 2)) 2.0) 0.75))
  52.      (novay (* height 0.3))
  53.      (novax (find-nova-x-coord logo-layer (* width 0.2) (* width 0.8) novay))
  54.      (novaradius (/ (min height width) 7.0))
  55.      (cx (/ width 2.0))
  56.      (cy (/ height 2.0))
  57.      (bx (+ cx (car (find-blend-coords w h))))
  58.      (by (+ cy (cdr (find-blend-coords w h))))
  59.      (bg-layer (car (gimp-layer-new img width height RGB-IMAGE "Background" 100 NORMAL-MODE)))
  60.      (glow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Glow" 100 NORMAL-MODE)))
  61.      (shadow-layer (car (gimp-layer-new img width height RGBA-IMAGE "Drop Shadow" 100 NORMAL-MODE)))
  62.      (bump-channel (car (gimp-channel-new img width height "Bump Map" 50 '(0 0 0)))))
  63.  
  64.     (gimp-context-push)
  65.  
  66.     (gimp-selection-none img)
  67.     (script-fu-util-image-resize-from-layer img logo-layer)
  68.     (gimp-image-add-layer img bg-layer 1)
  69.     (gimp-image-add-layer img glow-layer 1)
  70.     (gimp-image-add-layer img shadow-layer 1)
  71.     (gimp-image-add-channel img bump-channel 0)
  72.     (gimp-layer-set-preserve-trans logo-layer TRUE)
  73.  
  74.     (gimp-context-set-background '(0 0 0))
  75.     (gimp-edit-fill bg-layer BACKGROUND-FILL)
  76.     (gimp-edit-clear shadow-layer)
  77.     (gimp-edit-clear glow-layer)
  78.  
  79.     (gimp-selection-layer-alpha logo-layer)
  80.     (gimp-selection-grow img grow)
  81.     (gimp-selection-feather img feather)
  82.     (gimp-context-set-background glow-color)
  83.     (gimp-selection-feather img feather)
  84.     (gimp-edit-fill glow-layer BACKGROUND-FILL)
  85.  
  86.     (gimp-selection-layer-alpha logo-layer)
  87.     (gimp-selection-feather img shadow-feather)
  88.     (gimp-context-set-background '(0 0 0))
  89.     (gimp-selection-translate img offx offy)
  90.     (gimp-edit-fill shadow-layer BACKGROUND-FILL)
  91.  
  92.     (gimp-selection-none img)
  93.     (gimp-context-set-background '(31 31 31))
  94.     (gimp-context-set-foreground '(255 255 255))
  95.  
  96.     (gimp-edit-blend logo-layer FG-BG-RGB-MODE NORMAL-MODE
  97.              GRADIENT-BILINEAR 100 0 REPEAT-NONE FALSE
  98.              FALSE 0 0 TRUE
  99.              cx cy bx by)
  100.  
  101.     (plug-in-nova 1 img glow-layer novax novay glow-color novaradius 100 0)
  102.  
  103.     (gimp-selection-all img)
  104.     (gimp-context-set-pattern "Stone")
  105.     (gimp-edit-bucket-fill bump-channel PATTERN-BUCKET-FILL NORMAL-MODE 100 0 FALSE 0 0)
  106.     (plug-in-bump-map 1 img logo-layer bump-channel
  107.               135.0 45.0 4 0 0 0 0 FALSE FALSE 0)
  108.     (gimp-image-remove-channel img bump-channel)
  109.     (gimp-selection-none img)
  110.  
  111.     (gimp-context-pop)))
  112.  
  113.  
  114. (define (script-fu-starscape-logo-alpha img
  115.                     logo-layer
  116.                     size
  117.                     glow-color)
  118.   (begin
  119.     (gimp-image-undo-group-start img)
  120.     (apply-starscape-logo-effect img logo-layer size glow-color)
  121.     (gimp-image-undo-group-end img)
  122.     (gimp-displays-flush)))
  123.  
  124. (script-fu-register "script-fu-starscape-logo-alpha"
  125.             _"Sta_rscape..."
  126.             "Starscape using the Nova plug-in"
  127.             "Spencer Kimball"
  128.             "Spencer Kimball"
  129.             "1997"
  130.             "RGBA"
  131.                     SF-IMAGE      "Image"                     0
  132.                     SF-DRAWABLE   "Drawable"                  0
  133.             SF-ADJUSTMENT _"Effect size (pixels * 4)" '(150 1 1000 1 10 0 1)
  134.             SF-COLOR      _"Glow color"               '(28 65 188))
  135.  
  136. (script-fu-menu-register "script-fu-starscape-logo-alpha"
  137.              _"<Image>/Script-Fu/Alpha to Logo")
  138.  
  139.  
  140. (define (script-fu-starscape-logo text
  141.                   size
  142.                   fontname
  143.                   glow-color)
  144.   (let* ((img (car (gimp-image-new 256 256 RGB)))
  145.      (border (/ size 4))
  146.      (text-layer (car (gimp-text-fontname img -1 0 0 text border
  147.                           TRUE size PIXELS fontname))))
  148.     (gimp-image-undo-disable img)
  149.     (gimp-drawable-set-name text-layer text)
  150.     (apply-starscape-logo-effect img text-layer size glow-color)
  151.     (gimp-image-undo-enable img)
  152.     (gimp-display-new img)))
  153.  
  154. (script-fu-register "script-fu-starscape-logo"
  155.             _"Sta_rscape..."
  156.             "Starscape using the Nova plug-in"
  157.             "Spencer Kimball"
  158.             "Spencer Kimball"
  159.             "1997"
  160.             ""
  161.             SF-STRING     _"Text"               "Nova"
  162.             SF-ADJUSTMENT _"Font size (pixels)" '(150 1 1000 1 10 0 1)
  163.             SF-FONT       _"Font"               "Engraver"
  164.             SF-COLOR      _"Glow color"         '(28 65 188))
  165.  
  166. (script-fu-menu-register "script-fu-starscape-logo"
  167.              _"<Toolbox>/Xtns/Script-Fu/Logos")
  168.